function MaeCalc = calculateMAE(type, model, naive1, naive2, truevalue, R, C)

MaeCalc = zeros(1, 3);

switch type
    
    case 1
        MaeCalc(1,1) = mae(model-truevalue);
        MaeCalc(1,2) = mae(naive1-truevalue);
        MaeCalc(1,3) = mae(naive2-truevalue);
        
    case 2
        MaeCalc(1,1) = sqrt( sum( sum( (model-truevalue).^2 )));
        MaeCalc(1,2) = sqrt(sum( sum((naive1-truevalue).^2 )));
        MaeCalc(1,3) = sqrt(sum( sum( (naive2-truevalue).^2 )));
        
    case 3
        MaeCalc(1,1) = sum( sum(model.* abs(model-truevalue)));
        MaeCalc(1,2) = sum( sum(naive1.* abs(naive1-truevalue)));
        MaeCalc(1,3) = sum( sum(naive2.* abs(naive2-truevalue)));
        
    case 4
        v1=0; v2=0; v3=0;
        for m = R
            for n = C
                if model(R,C)~=0
                    v1 =  v1 + abs(model(m,n)-truevalue(m,n))./model(m,n) ;
                end
                
                if naive1(R,C)~=0
                    v2 =  v2 + abs(naive1(m,n)-truevalue(m,n))./naive1(m,n) ;
                end
                if naive2(R,C)~=0
                    v3 =  v3 + abs(naive2(m,n)-truevalue(m,n))./naive2(m,n) ;
                end
                
            end
        end
        
        MaeCalc(1,1) = v1;
        MaeCalc(1,2) = v2;
        MaeCalc(1,3) = v3;
        
        
    case  5
        a = mean(svd(truevalue));
        MaeCalc(1,1) = abs (mean(svd(model)) - a);
        MaeCalc(1,2) = abs (mean(svd(naive1)) - a);
        MaeCalc(1,3) = abs (mean(svd(naive2)) - a);
          
          
        
       
        
    case 6
        v1=0; v2=0; v3=0;
        for m = R
            for n = C
                if model(R,C)~=0
                    v1 =  v1 + ((model(m,n)-truevalue(m,n)).^2 )./model(m,n) ;
                end
                
                if naive1(R,C)~=0
                    v2 =  v2 + ((naive1(m,n)-truevalue(m,n)).^2 )./naive1(m,n) ;
                end
                
                if naive2(R,C)~=0
                    v3 =  v3 + ((naive2(m,n)-truevalue(m,n)).^2 )./naive2(m,n) ;
                end
                
            end
        end
        
        MaeCalc(1,1) = v1;
        MaeCalc(1,2) = v2;
        MaeCalc(1,3) = v3;
        
    case 7
        v1=0; v2=0; v3=0;
        for m = R
            for n = C
                if model(R,C)~=0
                    v1 =  v1 + ( model(m,n)-truevalue(m,n) ).^2  ./ ( model(m,n)*(1-model(m,n)) );
                end
                
                if naive1(R,C)~=0
                    v2 =  v2 + ( naive1(m,n)-truevalue(m,n) ).^2  ./ ( naive1(m,n)*(1-naive1(m,n)) );
                end
                
                if naive2(R,C)~=0
                    v3 =  v3 + ( naive2(m,n)-truevalue(m,n) ).^2  ./ ( naive2(m,n)*(1-naive2(m,n)) );
                end
                
            end
        end
        
        MaeCalc(1,1) = v1;
        MaeCalc(1,2) = v2;
        MaeCalc(1,3) = v3;
        
        
    case 8 % D1^2
        v1=0; v2=0; v3=0;
        for m = R
            for n = C
                mD1_1 = (m - n)* (model(m, n) - truevalue(m, n));
                mD1_2 = (m - n)* (naive1(m, n) - truevalue(m, n));
                mD1_3 = (m - n)* (naive2(m, n) - truevalue(m, n));
                
                
                if n ~= C %D3
                    v1 = v1 + mD1_1;
                    v2 = v2 + mD1_1;
                    v3 = v3 + mD1_1;
                    
                else
                    v1 = v1 + mD1_1*C^2;
                    v2 = v1 + mD1_2*C^2;
                    v3 = v1 + mD1_3*C^2;
                    
                end
                
            end
        end
        
%         MaeCalc(1,1) = v1;
%         MaeCalc(1,2) = v2;
%         MaeCalc(1,3) = v3;
        
                MaeCalc(1,1) = abs(v1);
                MaeCalc(1,2) = abs(v2);
                MaeCalc(1,3) = abs(v3);
        
    case 9 % D2^2
        v1=0; v2=0; v3=0;
        for m = R
            for n = C
                mD2_1 = (m - n)* (model(m, n) - truevalue(m, n))/model(m, n);
                mD2_2 = (m - n)* (naive1(m, n) - truevalue(m, n))/naive1(m, n);
                mD2_3 = (m - n)* (naive2(m, n) - truevalue(m, n))/naive2(m, n) ;
                
                
                if n ~= C %D3
                    v1 = v1 + mD2_1;
                    v2 = v2 + mD2_1;
                    v3 = v3 + mD2_1;
                    
                else
                    v1 = v1 + mD2_1*C^2;
                    v2 = v1 + mD2_2*C^2;
                    v3 = v1 + mD2_3*C^2;
                    
                end
                
            end
        end
        
                MaeCalc(1,1) = abs(v1);
                MaeCalc(1,2) = abs(v2);
                MaeCalc(1,3) = abs(v3);
%         MaeCalc(1,1) = v1;
%         MaeCalc(1,2) = v2;
%         MaeCalc(1,3) = v3;
        
        
    case 10 %D3^2
        v1=0; v2=0; v3=0;
        for m = R
            for n = C
                mD3_1 = (m - n)* sign(model(m, n) - truevalue(m, n))*(model(m, n) - truevalue(m, n))^2;
                mD3_2 = (m - n)* sign(naive1(m, n) - truevalue(m, n))*(naive1(m, n) - truevalue(m, n))^2;
                mD3_3 = (m - n)* sign(naive2(m, n) - truevalue(m, n))*(naive2(m, n) - truevalue(m, n))^2;
                
                if n ~= C %D3
                    v1 = v1 + mD3_1;
                    v2 = v2 + mD3_1;
                    v3 = v3 + mD3_1;
                else
                    v1 = v1 + mD3_1*C;
                    v2 = v1 + mD3_2*C;
                    v3 = v1 + mD3_3*C;
                end
                
            end
        end
        
                MaeCalc(1,1) = abs(v1);
                MaeCalc(1,2) = abs(v2);
                MaeCalc(1,3) = abs(v3);
%         MaeCalc(1,1) = v1;
%         MaeCalc(1,2) = v2;
%         MaeCalc(1,3) = v3;
        
    case 11 %D4^2
        v1=0; v2=0; v3=0;
        for m = R
            for n = C
                mD4_1 = (m - n)* sign(model(m, n) - truevalue(m, n))*(model(m, n) - truevalue(m, n))^2/model(m, n);
                mD4_2 = (m - n)* sign(naive1(m, n) - truevalue(m, n))*(naive1(m, n) - truevalue(m, n))^2/naive1(m, n);
                mD4_3 = (m - n)* sign(naive2(m, n) - truevalue(m, n))*(naive2(m, n) - truevalue(m, n))^2/naive2(m, n);
                
                if n ~= C %D3
                    v1 = v1 + mD4_1;
                    v2 = v2 + mD4_1;
                    v3 = v3 + mD4_1;
                else
                    v1 = v1 + mD4_1*C;
                    v2 = v1 + mD4_2*C;
                    v3 = v1 + mD4_3*C;
                end
                
            end
        end
        
        %         MaeCalc(1,1) = v1;
        %         MaeCalc(1,2) = v2;
        %         MaeCalc(1,3) = v3;
        MaeCalc(1,1) = abs(v1);
        MaeCalc(1,2) = abs(v2);
        MaeCalc(1,3) = abs(v3);
        
        
    otherwise
        disp('Over type numbers');
        
end

end